package com.wlyuan.open.application.listener;

import com.wlyuan.core.domain.event.DomainEventListener;
import com.wlyuan.open.domain.api.event.CreateApiLogEvent;
import com.wlyuan.open.domain.api.service.OpenApiLogService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.springframework.stereotype.Service;

/**
 * @author lijing
 */
@Service
@RequiredArgsConstructor
@Slf4j
public class CreateApiLogEventListener implements DomainEventListener<CreateApiLogEvent> {
    private final OpenApiLogService openApiLogService;

    @Override
    @Subscribe(sticky = true, threadMode = ThreadMode.ASYNC)
    public void handle(CreateApiLogEvent event) {
        openApiLogService.add(event.getCreate());
    }
}
